package com.yf.course.modules.course.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yf.course.modules.course.entity.CourseRefDir;
import com.yf.course.modules.course.entity.CourseRefPoint;
import com.yf.course.modules.course.mapper.CourseRefDirMapper;
import com.yf.course.modules.course.mapper.CourseRefPointMapper;
import com.yf.course.modules.course.service.CourseRefDirService;
import com.yf.course.modules.course.service.CourseRefPointService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;

import java.util.List;

/**
 * @author wangjun
 * @date 2025/2/27 20:05
 */
@Service
public class CourseRefPointServiceImpl  extends ServiceImpl<CourseRefPointMapper, CourseRefPoint> implements CourseRefPointService {

    @Autowired
    private CourseRefPointMapper baseMapper;

    @Override
    public void save(String courseId, List<CourseRefPoint> list) {
        QueryWrapper<CourseRefPoint> wrapper = new QueryWrapper<>();
        wrapper.lambda().eq(CourseRefPoint::getCourseId, courseId);
        this.remove(wrapper);

        if(CollectionUtils.isEmpty(list)){
            return;
        }

        this.saveBatch(list);
    }

    @Override
    public void saveNewItem(String classId, List<CourseRefPoint> saveDirs) {

    }

    @Override
    public void saveNewKnowledgePoint(CourseRefPoint knowledgePoint) {
        this.save(knowledgePoint);
    }

}
